{template '_header'}

<div class="page-header">
    当前位置：<span class="text-primary">{if !empty($item['id'])}编辑{else}添加{/if}运营商</span>
</div>

<div class="page-content">
    <div class="page-sub-toolbar">
        <span class=''>
		{ifp 'operator.add'}
                <a class="btn btn-primary btn-sm" href="{php echo webUrl('operator/post')}">添加新运营商</a>
            {/if}
            <a class="btn btn-default  btn-sm" href="{php echo webUrl('operator')}">返回列表</a>
        </span>
    </div>

<form id="setform"  {ifp 'operator.edit'}action="" method="post"{/if} class="form-horizontal form-validate">

<input type="hidden" name="id" value="{$item['id']}" />

<div class="tabs-container">
    <div class="tab-content ">
        <div class="tab-pane active" id="tab_basic">

            <div class="form-group">
                <label class="col-sm-2 control-label">排序</label>
                <div class="col-sm-8">
                    {ifp 'operator.edit'}
                    <input type="text" class="form-control" name="displayorder" value="{$item['displayorder']}" data-rule-required="true"/>
                    {else}
                    <div class="form-control-static">
                        {$item['displayorder']}
                    </div>
                    {/if}
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label must">运营商</label>
                <div class="col-sm-8">
                    {ifp 'operator.edit'}
                    {php echo tpl_selector('uid',array('key'=>'id','text'=>'realname', 'thumb'=>'avatar','multi'=>0,'placeholder'=>'昵称/姓名/手机号','buttontext'=>'选择运营商', 'items'=>$uid,'url'=>webUrl('user/query') ))}
                    {else}
                    <div class="form-control-static">
                        {$types[$item['uid']]}
                    </div>
                    {/if}
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label must">运营商级别</label>
                <div class="col-sm-8">
                    {ifp 'operator.edit'}
                    <select name='type' class='form-control ' id="seltype">
                        <option value="0" {if empty($item['type'])} selected  {/if}>请选择级别</option>
                        {loop $types $k $v}
                        <option value="{$k}" {if $k == $item['type']} selected  {/if}>{$v}</option>
                        {/loop}
                    </select>
                    {else}
                    <div class="form-control-static">
                        {$types[$item['type']]}
                    </div>
                    {/if}
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">负责区域</label>
                <div class="col-sm-9 col-xs-12">
                    {ifp 'operator.edit'}
                    <p>
                        <select id="sel-provance" name="province" onChange="selectCity();" class="select form-control" style="width:130px;display:inline;">
                            <option value="" selected="true">省/直辖市</option>
                        </select>
                        <select id="sel-city" name="city" onChange="selectcounty(0)" class="select form-control" style="width:135px;display:inline;">
                            <option value="" selected="true">请选择</option>
                        </select>
                        <select id="sel-area" name="dist" class="select form-control" style="width:130px;display:inline;">
                            <option value="" selected="true">请选择</option>
                        </select>
                    </p>
                    {else}
                    <div class='form-control-static'>{$item['province']} {if $item['type'] == 2} {$item['city']} {$item['dist']}{/if}</div>
                    {/if}
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">显示状态</label>
                <div class="col-sm-8">
                    {ifp 'operator.edit'}
                    <label class="radio-inline">
                        <input type="radio" name="status" value="1" {if $item['status']==1}checked{/if} />是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="status" value="0" {if $item['status']==0}checked{/if}/> 否
                    </label>
                    {else}
                    <div class="form-control-static">
                        {if $item['status']==0}
                        否
                        {elseif $item['stauts']==1}
                        是
                        {/if}
                    </div>
                    {/if}
                </div>
            </div>
        </div>
    </div>
</div>

{ifp 'operator.edit'}
<div class="form-group">
    <label class="col-sm-2 control-label"></label>
    <div class="col-sm-9 col-xs-12">
        <input type="submit"  value="提交" class="btn btn-primary" />
    </div>
</div>
{/if}

</form>

<script type="text/javascript" src="../addons/mx_shop/static/js/cascade.js"></script>
<script>
    $(function(){
        cascdeInit("{php echo $new_area}","0","{php echo $item['province']}","{php echo $item['city']}","{php echo $item['dist']}");
    });

    $('#seltype').change(function(){
        var _val = $(this).val();
        if(_val == 1){
            $('#sel-city').hide();
            $('#sel-area').hide();
        }else{
            $('#sel-city').show();
            $('#sel-area').show();
        }
    });
    var _type = "{$item['type']}";
    if(_type == 1){
        $('#sel-city').hide();
        $('#sel-area').hide();
    }
</script>
</div>
{template '_footer'}